//
//  YWNoContentView2.m
//  YueshengToutiao
//
//  Created by jun peng on 2022/1/25.
//  Copyright © 2022 YW. All rights reserved.
//

#import "YWNoContentView2.h"

@interface YWNoContentView2 ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *explainLabel;
@property (weak, nonatomic) IBOutlet UIButton *refreshBtn;
- (IBAction)refreshBtnCLick:(UIButton *)sender;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconCenterYConstraint;

@end

@implementation YWNoContentView2

-(void)awakeFromNib{
    [super awakeFromNib];
    
    self.refreshBtn.layer.cornerRadius = 19;
}

+(instancetype)noContentView{
    
    return [[NSBundle mainBundle] loadNibNamed:@"YWNoContentView2" owner:nil options:nil].lastObject;
}


-(void)setNoContentType:(YWNoContentView2Type)noContentType{
    self.iconCenterYConstraint.constant = -100;
    _noContentType = noContentType;
    self.refreshBtn.hidden = NO;
    switch (noContentType) {
        case YWNoContentView2Type_Error404:
        {
            self.iconView.image = [UIImage imageNamed:@"网络出错404"];
            self.titleLabel.text = @"错误代码404";
            self.explainLabel.text = @"哎呦，该网络出错了";
            [self.refreshBtn setTitle:@"重新加载" forState:UIControlStateNormal];
        }
            break;
        case YWNoContentView2Type_NoClass:
        {
            self.iconView.image = [UIImage imageNamed:@"暂无课程"];
            self.titleLabel.text = @"暂无课程";
            self.explainLabel.text = @"";
            [self.refreshBtn setTitle:@"返回列表" forState:UIControlStateNormal];
        }
            break;
        case YWNoContentView2Type_NoContent:
        {
            self.iconView.image = [UIImage imageNamed:@"暂无内容2"];
            self.titleLabel.text = @"暂无内容";
            self.explainLabel.text = @"没有找到相关内容";
            [self.refreshBtn setTitle:@"刷新" forState:UIControlStateNormal];
        }
            break;
        case YWNoContentView2Type_NoSearchContent:
        {
            self.iconView.image = [UIImage imageNamed:@"暂无内容2"];
            self.titleLabel.text = @"没有搜索结果";
            self.explainLabel.text = @"没有找到相关内容";
            [self.refreshBtn setTitle:@"刷新" forState:UIControlStateNormal];
        }
            break;
        case YWNoContentView2Type_NoConcernContent:
        {
            self.iconView.image = [UIImage imageNamed:@"暂无内容2"];
            self.titleLabel.text = @"还没有关注";
            self.explainLabel.text = @"快去关注您喜爱的老师吧";
            [self.refreshBtn setTitle:@"更多老师" forState:UIControlStateNormal];
        }
            break;
        case YWNoContentView2Type_NoContentButNotConformBtn:
        {
            self.iconCenterYConstraint.constant = -50;
            self.iconView.image = [UIImage imageNamed:@"暂无内容2"];
            self.titleLabel.text = @"暂无内容";
            self.explainLabel.text = @"没有找到相关内容";
            [self.refreshBtn setTitle:@"刷新" forState:UIControlStateNormal];
            self.refreshBtn.hidden = YES;
        }
            break;
        default:
            break;
    }
    
    
    
}


- (IBAction)refreshBtnCLick:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(noContentView2DidClickRefreshBtn:)]) {
        [self.delegate noContentView2DidClickRefreshBtn:self];
    }
}


@end
